package com.example.kaoqinmanager.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.kaoqinmanager.R;
import com.example.kaoqinmanager.bean.DaKaTable;

import org.w3c.dom.Text;

import java.util.List;

/**
 * @author ypk
 * 创建日期：2021/12/15  10:53
 * 描述：
 */
public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.RecordViewHolder> {

    private Context context;
    List<DaKaTable> list;

    public RecordAdapter(Context context, List<DaKaTable> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public RecordViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_record, parent, false);
        return new RecordViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull RecordViewHolder holder, int position) {
        holder.tvTime.setText(list.get(position).getTime());
        holder.tvName.setText(list.get(position).getUsername());
        holder.tvStatus.setText(list.get(position).getDakaStatus());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class RecordViewHolder extends RecyclerView.ViewHolder {

        private TextView tvTime;
        private TextView tvName;
        private TextView tvStatus;

        public RecordViewHolder(@NonNull View itemView) {
            super(itemView);
            tvTime = itemView.findViewById(R.id.tvTime);
            tvName = itemView.findViewById(R.id.tvName);
            tvStatus = itemView.findViewById(R.id.tvStatus);
        }
    }


}
